package Zidingyi;

import Zidingyi.exception.Username;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        //自定义运行时异常
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String name = sc.next();
        if (name.equals("admin")){
            System.out.println("用户名已存在！");
            throw  new Username("用户名已存在，请换一个试试");
        }else {
            System.out.println("用户名可用！");
        }
        System.out.println("===========");


        //编译时异常


    }
}
